home *** CD-ROM | disk | FTP | other *** search
/ Practical Algorithms for Image Analysis / Practical Algorithms for Image Analysis.iso / BUILD.SH next >
Linux/UNIX/POSIX Shell Script  |  1999-09-11  |  3KB  |  203 lines

  1. #!/bin/ksh
  2. #
  3. # build.sh
  4. #
  5. # Master makefile script for compiling all libraries and programs
  6. # for a LINUX operating system.
  7. #
  8. # Practical Algorithms for Image Analysis
  9. #
  10. # Copyright (c) 1997, 1998, 1999 M. Seul, L. O'Gorman, M. J. Sammon
  11. # NOTE: for a successful compilation
  12. # the following are suggested:
  13. # 1) gcc version 2.7.2
  14. # 2) LINUX kernel version 2.0.0
  15. #
  16.  
  17. checkforce()
  18. {
  19.         if [ $force -eq 1 ]
  20.         then
  21.                 print "$me: $1: make clean"
  22.                 make clean
  23.         fi
  24. }
  25.  
  26. checkmake()
  27. {
  28.     if [ "$?" != "0" ]
  29.     then
  30.         echo "$me: MAKE FAILED BUILDING $dir"
  31.         if [ $ignoreErrors -eq 0 ]; then
  32.             cd $HERE
  33.             exit 2
  34.         fi
  35.     fi
  36. }
  37.  
  38. usage()
  39. {
  40.     echo "usage: $me [-dgi] [-S dir] [force|clean]" 1>&2 
  41.     echo "-d = print directory build sequence on stdout and exit" 1>&2 
  42.     echo "-g = compile and link with -g" 1>&2 
  43.     echo "-i = ignore errors" 1>&2 
  44.     echo '-S dir = start build at directory named dir' 1>&2 
  45. }
  46.  
  47. me=build.sh
  48. HERE=`pwd`
  49.  
  50. libs="libtiff libimage libip"
  51.  
  52. progs="\
  53. ch_2.1/histstats \
  54. ch_2.2/histex \
  55. ch_2.2/histexx \
  56. ch_2.2/histramp \
  57. ch_2.3/combine \
  58. ch_2.3/imgarith \
  59. ch_2.3/imgbool \
  60. ch_2.3/inv \
  61. ch_2.4/imgrotate \
  62. ch_2.4/xscale \
  63. ch_2.5/rgb2gray \
  64. ch_3.1/xconv \
  65. ch_3.2/lpfltr \
  66. ch_3.2/medfltr \
  67. ch_3.3/bc \
  68. ch_3.4/peak \
  69. ch_3.5/bcd \
  70. ch_3.6/subsample \
  71. ch_3.6/subsampleNI \
  72. ch_3.7/multires \
  73. ch_3.8/xcorr \
  74. ch_3.9/binarize \
  75. ch_3.9/threshe \
  76. ch_3.9/threshk \
  77. ch_3.9/threshm \
  78. ch_3.9/thresho \
  79. ch_4.1/cellog \
  80. ch_4.1/morph \
  81. ch_4.10/hough \
  82. ch_4.2/kfill \
  83. ch_4.3/contour \
  84. ch_4.3/xah \
  85. ch_4.3/xcc \
  86. ch_4.3/xcp \
  87. ch_4.3/xrg \
  88. ch_4.4/xfm \
  89. ch_4.4/xpm \
  90. ch_4.5/xbdy \
  91. ch_4.6/xph \
  92. ch_4.7/thin \
  93. ch_4.8/thinw \
  94. ch_4.9/globalfeats \
  95. ch_4.9/imggrid \
  96. ch_4.9/profile \
  97. ch_5.1/pcc \
  98. ch_5.1/pccde \
  99. ch_5.1/pccdump \
  100. ch_5.1/pccfeat \
  101. ch_5.2/linefeat \
  102. ch_5.2/linerid \
  103. ch_5.2/linexy \
  104. ch_5.2/structfeat \
  105. ch_5.2/structrid \
  106. ch_5.3/fitpolyg \
  107. ch_5.4/fitcrit \
  108. ch_5.5/fitline \
  109. ch_5.6/fitspline \
  110. ch_5.7/eh_seg \
  111. ch_5.7/eh_sgl \
  112. ch_5.7/xsgll \
  113. ch_6.1/spp \
  114. ch_6.1/xvor \
  115. ch_6.2/dpp \
  116. ch_6.2/xptstats \
  117. ch_6.2/xvora \
  118. ch_6.3/xsgt \
  119. ch_6.4/xknn \
  120. ch_7.1/powspec \
  121. ch_7.2/fltrfreq \
  122. "
  123.  
  124. # Build libraries first
  125. buildSequence="$libs $progs"
  126. beginDir=
  127. force=0
  128. target=all
  129. makeopts=
  130. here=$HERE
  131. ignoreErrors=0
  132. while getopts ':digS:?' arg
  133. do
  134.     case $arg in
  135.     [d])
  136.         for i in $buildSequence
  137.         do
  138.             print "$i"
  139.         done
  140.         exit 0;;
  141.     [i])
  142.         ignoreErrors=1;;
  143.     [g])
  144.         G="-g";;
  145.     [S])
  146.         beginDir=$OPTARG;;
  147.     '?')
  148.         usage
  149.         exit 0;;
  150.     *)
  151.         usage
  152.         exit 2;;
  153.     esac
  154. done
  155. shift `expr $OPTIND - 1`
  156. if [ "$1" = "" ]
  157. then
  158.     print "$me: starting a normal build"
  159. else
  160.     while [ "$1" != "" ]
  161.     do
  162.         case $1 in
  163.         force|FORCE)
  164.             force=1
  165.             print "$me: starting forced complete build"
  166.             ;;
  167.         clean)
  168.             target=clean
  169.             ;;
  170.         *)
  171.             print "$me: unrecognized command-line parameter $1 (ignored)"
  172.             ;;
  173.         esac
  174.         shift
  175.     done
  176. fi
  177.  
  178. building=0
  179. if [ "$beginDir" = "" ]; then
  180.     beginDir=libtiff
  181. fi
  182.  
  183. for dir in $buildSequence
  184. do
  185.     if [ $building -eq 0 ]; then
  186.         if [ "$beginDir" = "$dir" ]; then
  187.             building=1
  188.         fi
  189.     fi
  190.     if [ $building -eq 0 ]; then
  191.         echo "$me: skipping $dir" 1>&2
  192.     else
  193.         if [ -d $dir ]; then
  194.             cd $dir
  195.             checkforce $dir
  196.             make $makeopts $target
  197.             checkmake
  198.         fi
  199.     fi
  200.     cd $here
  201. done
  202.